<?php

namespace App\Jobs;

use App\Service\users\UsersService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class WithdrawQueue implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private mixed $uid;
    private mixed $num;
    private mixed $type;
    private mixed $remark;
    private mixed $operator;

    /**
     * Create a new job instance.
     */
    public function __construct($uid, $num, $type, $remark, $operator)
    {
        $this->uid = $uid;
        $this->num = $num;
        $this->type = $type;
        $this->remark = $remark;
        $this->operator = $operator;
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {

        try {

            UsersService::instance()->amountRecord($this->uid, $this->num, $this->type, $this->remark, $this->operator);

        } catch (\Exception $e) {
            log::error(date('Y-m-d h:i:s',time()).' 平台消息推送失败:'.$e->getMessage());
        }

    }
}
